<template>
  <div>
    <van-form @submit="onSubmit">
      <van-field
        name="radio"
        label="审核情况"
        :required="true"
        :rules="[{ required: true, message: '请选择审核结果' }]"
      >
        <template #input>
          <van-radio-group v-model="form.status" direction="horizontal">
            <van-radio name="3">审核通过</van-radio>
            <van-radio name="4">审核不通过</van-radio>
          </van-radio-group>
        </template>
      </van-field>
      <van-field
        v-model="form.auditDesc"
        rows="2"
        autosize
        label="审核说明"
        type="textarea"
        maxlength="100"
        placeholder="请填写审核说明"
        show-word-limit
        :required="false"
      />
      <div style="margin: 0.5rem;">
        <van-button round block type="info" native-type="submit">提交</van-button>
      </div>
    </van-form>
  </div>
</template>
<script>
import { Toast } from 'vant'
import {
  auditCompany, // 安全
  HbAuditCompany, // 环保
  NyAuditCompany, // 能源
  TpfAuditCompany, // 碳排放
  XfAuditCompany// 消防
} from '@/api/commonPage/AnnualWork'

export default {
  components: {
  },
  data() {
    return {
      form: {
        status: '3',
        auditDesc: '',
        workCompanyId: ''
      },
      api: {
        安全生产: {
          auditCompany: auditCompany
        },
        碳排放管理: {
          auditCompany: TpfAuditCompany
        },
        环保管理: {
          auditCompany: HbAuditCompany
        },
        能源管理: {
          auditCompany: NyAuditCompany
        },
        消防管理: {
          auditCompany: XfAuditCompany
        }
      }
    }
  },

  methods: {
    onSubmit() {
      const { current } = this.$route.query
      const item = JSON.parse(this.$route.query.item)
      this.form.workCompanyId = item.workCompanyId
      this.api[current].auditCompany({
        status: this.form.status,
        auditDesc: this.form.auditDesc,
        workCompanyId: this.form.workCompanyId
      }).then(res => {
        if (res.status === 0) {
          this.$emit('input', false)
          this.$emit('back')
          Toast.success(res.data)
        }
      })
    }
  }
}
</script>
<style scoped>

</style>
